DYLIB_FLAG=-dynamiclib

all: libSpriteContour.a libSpriteContour.so demo demo_static

libSpriteContour.a:
	$(CXX) -O3 -c sprite_contour.cpp $$(sdl-config --cflags)
	\ar rcs $@ sprite_contour.o
	\ranlib $@
	\rm -f sprite_contour.o

libSpriteContour.so:
	$(CXX) -fPIC -O3 -c sprite_contour.cpp $$(sdl-config --cflags)
	$(CXX) $(DYLIB_FLAG) -o $@ sprite_contour.o
	\rm -f sprite_contour.o

demo: libSpriteContour.a
	$(CXX) -o $@ demo.cpp libSpriteContour.a $$(sdl-config --cflags --libs) \
  -lSDL_image -DUSE_SDL_GFX -lSDL_gfx

demo_static: libSpriteContour.a
	$(CXX) -o $@ demo.cpp libSpriteContour.a -DUSE_SDL_GFX \
		$$(sdl-config --cflags --static-libs) \
	/sw/lib/libSDL_image.a /sw/lib/libSDL_gfx.a
	\cp $@ app/demo

clean:
	\rm -f *.o *.a *.so demo demo_static app/demo

